package com.wyz.socket.core.base.packet.bytes;

import com.wyz.socket.core.base.packet.AbstractSendPacket;

import java.io.ByteArrayInputStream;

public class BytesSendPacket extends AbstractSendPacket<ByteArrayInputStream> {

    private final byte[] bytes ;

    public BytesSendPacket(byte[] bytes) {
        this.bytes = bytes;
        length = bytes.length;
    }

    @Override
    public byte type() {
        return TYPE_MEMORY_BYTES;
    }

    @Override
    protected ByteArrayInputStream createStream() {
        return new ByteArrayInputStream(bytes);
    }

    @Override
    public String toString() {
        return "BytesSendPacket = "+new String(bytes);
    }
}
